//
//  OrderDetailsViewController.swift
//  LiuheCommunity
//
//  Created by 罗恒 on 2018/1/20.
//  Copyright © 2018年 luo. All rights reserved.
//

import UIKit

class OrderDetailsViewController: UIViewController{
    
    var activityVC:ActivityDetailViewController?
    var QrVC:QRViewController?
    var model:MyModel?
    

    
    @IBOutlet weak var actId: UILabel!
    
    @IBOutlet weak var timeOne: UILabel!
    
    @IBOutlet weak var orderNum: UILabel!
    
    @IBOutlet weak var name: UILabel!
    
    @IBOutlet weak var phoneNum: UILabel!
   
    @IBOutlet weak var classImage: UIImageView!
    
    @IBOutlet weak var classTitle: UILabel!
    
    @IBOutlet weak var activityView: UIView!
    

    @IBOutlet weak var qrImg: UIImageView!
    
    @IBOutlet weak var timeTwo: UILabel!
    
    @IBOutlet weak var money: UILabel!
    
    @IBOutlet weak var moneyTwo: UILabel!
    
    @IBOutlet var bgView: UIView!
    
    var modelArray:NSMutableArray? = NSMutableArray()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.title = "订单详情"

        
        qrImg.addGestureRecognizer(UITapGestureRecognizer.init(target: self, action: #selector(qrClick)))
        qrImg.isUserInteractionEnabled = true
        
        activityView.addGestureRecognizer(UITapGestureRecognizer.init(target: self, action: #selector(viewClick)))
    }
    
    override func viewWillAppear(_ animated: Bool) {
        self.tabBarController?.hidesBottomBarWhenPushed = true;
        
        self.tabBarController?.tabBar.isHidden = true//隐藏tabbar
        
        self.automaticallyAdjustsScrollViewInsets = false//移除隐藏后留下的空白
      
        orderNum.text = model?.out_trade_no
        timeOne.text = model?.time_start
        classTitle.text = model?.title
        money.text = model?.discountedPrice
        moneyTwo.text = model?.discountedPrice
        let picURL = NSURL.init(string: (model?.imgMainUrl)!)
        classImage.sd_setImage(with: picURL! as URL)
        timeTwo.text = model?.activityDate
        
        
        WebService.shareInstance.UserInfo{(isSuccess,par)in
            if isSuccess == true{
                let model = ShareInfo.shareInstance.infoAc
                self.name.text = model?.name
                self.phoneNum.text = model?.phoneNo
            }else{
                let a = ""
                
                MBProgressHUD.showToast(to: self.view, withText: a)
                
            }
            
        }
        
    }
    
    @objc func qrClick(){
        if (QrVC ==  nil) {
            QrVC = QRViewController()
        }
        let qrVc = QRViewController()
        qrVc.acId = model?.activityId
        self.navigationController?.pushViewController(qrVc, animated: true)
    }
    @objc func viewClick(){
        if(activityVC == nil){
            activityVC = ActivityDetailViewController()
        }
        
        let vc = ActivityDetailViewController()
        vc.acId = model?.activityId
        self.navigationController?.pushViewController(vc, animated: true)


    }

}
